$(function(){
	$(document).on('click','#addperson',function(){
		    var number = document.getElementById("number").value;
			var name = document.getElementById("name").value;
			var age = document.getElementById("age").value;
			var sex = document.getElementById("sex").value;
			var phone = document.getElementById("phone").value;
			var address = document.getElementById("address").value;
			var salary = document.getElementById("salary").value;
			var positionId = document.getElementById("position_id").value;
			var sectorId = document.getElementById("sector_id").value;

			var param = {
				number: number,
                name: name,
				age: age,
				sex: sex,
				phone: phone,
				address: address,
				salary: salary,
				sectorId: sectorId,
				positionId: positionId
			};
			$.ajax({
				url: '/person/index.php/Home/addperson/personAdd',
				type: 'POST',
				dataType: 'json',
				data: param,
				success: function(data){
					console.log(data);
					if(data.code == 0){
						layer.msg('添加成功',{icon: 1});						
					}
				},
				error: function(xhr){
					console.log(xhr);
				}
			});
	});

	$(document).on('click','#editperson',function(){

		    var id = document.getElementById("id").value;
		    var number = document.getElementById("number").value;
			var name = document.getElementById("name").value;
			var age = document.getElementById("age").value;
			var sex = document.getElementById("sex").value;
			var phone = document.getElementById("phone").value;
			var address = document.getElementById("address").value;
			var salary = document.getElementById("salary").value;
			var positionId = document.getElementById("position_id").value;
			var sectorId = document.getElementById("sector_id").value;

			var param = {
				id: id,
				number: number,
                name: name,
				age: age,
				sex: sex,
				phone: phone,
				address: address,
				salary: salary,
				sectorId: sectorId,
				positionId: positionId
			};
			$.ajax({
				url: '/person/index.php/Home/Editperson/personEdit',
				type: 'POST',
				dataType: 'json',
				data: param,
				success: function(data){
					console.log(data);
					if(data.code == 0){
						layer.msg('修改成功',{icon: 1});						
					}
				},
				error: function(xhr){
					console.log(xhr);
				}
			});
	});
});